Skip to content

fix: trailing comma inside delimiters no longer over-indents#27

Merged
jeanpaulsio merged 3 commits into
mainfrom
fix/hash-trailing-comma-indent
Mar 27, 2026
Merged

fix: trailing comma inside delimiters no longer over-indents#27
jeanpaulsio merged 3 commits into
mainfrom
fix/hash-trailing-comma-indent

Conversation

@jeanpaulsio

Copy link
Copy Markdown
Owner

Summary

  • Trailing commas inside {}, [], () no longer add an extra indent level. Added isInsideDelimiter() to detect when we're inside an unclosed bracket and skip the continuation indent (since delimitedIndent already handles it).
  • Fixed the CONTINUATION regex's trailing-comment capture (#.*)?$ which was matching #{interpolation} inside strings as a "comment" — e.g. "Hello, #{@name}!" was treated as a trailing comma + comment. Changed to (#(?:[^{].*)?)?$.

Test plan

  • 13 new test cases in section 33 covering hashes, arrays, method args, nested constructs, bare call continuations, and interpolated strings
  • 1 previously-skipped test (28b array of hashes) unskipped and passing
  • Full test suite passes with zero regressions (261 indent tests, 105 grammar tests, 139 highlight tests, + all others)
  • Benchmarks unchanged

Two bugs fixed:

1. Trailing commas inside delimited constructs ({}, [], ()) added an
   extra indent level because the CONTINUATION regex matched them and
   added cx.unit on top of what delimitedIndent already provided. Added
   isInsideDelimiter() to skip continuation indent when inside an
   unclosed bracket.

2. The CONTINUATION regex's trailing-comment capture (#.*)?$ matched
   #{interpolation} inside strings as a "comment", so lines like
   "Hello, #{@name}!" were treated as ending with a trailing comma.
   Changed to (#(?:[^{].*)?)?$ to exclude #{.

13 new test cases (section 33), 1 previously-skipped test unskipped.
@jeanpaulsio jeanpaulsio merged commit 68ce567 into main Mar 27, 2026
1 check passed
@jeanpaulsio jeanpaulsio deleted the fix/hash-trailing-comma-indent branch March 27, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant